package cat.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageInfo;

import cat.entity.Article;
import cat.service.ArticleService;

/**
 * 文章 控制层
 */
@Controller @RequestMapping("/article")
public class ArticleController {
	@Resource
	private ArticleService articleService;
	
	/**
	 * 转到文章列表页
	 * @param pageIndex 用于分页,表是当前是第几页
	 * @param pageSize 用于分页,表示每页显示多少条数据
	 */
	@RequestMapping(value="")
	public String index(@RequestParam(required = false,defaultValue = "1") Integer pageIndex, 			
						@RequestParam(required = false,defaultValue = "10")  Integer pageSize, ModelMap m) {
		System.out.println("--------------------------------------------");
		
		PageInfo<Article>  articlePageInfo =articleService.getPageArticleList(pageIndex,pageSize);
	
		m.put("pageInfo", articlePageInfo);
		
		m.put("pageUrlPrefix","article?pageIndex");  //把前缀传给分页的页面
		return "Article/article-list";
	}
	}
